// module_test.nr - Comprehensive module import tests with flexible syntax

// Demonstrate all flexible import syntax styles:

// Style 1: Traditional ES6 with braces
import { add, subtract, multiply, divide } from "./mathlib.nr"
import { calculate_area, get_pi_times_100 } from "./mathlib.nr"

// Style 2: Simplified without braces (recommended)
import add as plus, subtract as minus from "./mathlib.nr"

// Style 3: Python-style (from first)
from "./mathlib.nr" import multiply as times

func test_module_import_suite() {
    println("╔════════════════════════════════════════════════╗")
    println("║     Comprehensive Module Import Tests         ║")
    println("╚════════════════════════════════════════════════╝")
    println()

    var total_tests int = 0
    var passed_tests int = 0

    // Test 1: Traditional ES6 imports with braces
    println("─────────────────────────────────────────────────")
    println("[Test 1] Traditional: import { a, b } from \"...\"")
    println("─────────────────────────────────────────────────")
    total_tests = total_tests + 1
    var result1 int = add()
    print("add() = ")
    println(result1)
    assert(result1 == 30, "add() should return 30")
    println("  ✓ add() == 30")
    passed_tests = passed_tests + 1
    println()

    total_tests = total_tests + 1
    var result2 int = subtract()
    print("subtract() = ")
    println(result2)
    assert(result2 == 35, "subtract() should return 35")
    println("  ✓ subtract() == 35")
    passed_tests = passed_tests + 1
    println()

    total_tests = total_tests + 1
    var result3 int = multiply()
    print("multiply() = ")
    println(result3)
    assert(result3 == 42, "multiply() should return 42")
    println("  ✓ multiply() == 42")
    passed_tests = passed_tests + 1
    println()

    total_tests = total_tests + 1
    var result4 int = divide()
    print("divide() = ")
    println(result4)
    assert(result4 == 10, "divide() should return 10")
    println("  ✓ divide() == 10")
    passed_tests = passed_tests + 1
    println()

    // Test 2: Simplified syntax without braces
    println("─────────────────────────────────────────────────")
    println("[Test 2] Simplified: import a as x, b as y from \"...\"")
    println("─────────────────────────────────────────────────")
    total_tests = total_tests + 1
    var result_plus int = plus()
    print("plus() (aliased from add) = ")
    println(result_plus)
    assert(result_plus == 30, "plus() should return 30")
    println("  ✓ plus() == 30")
    passed_tests = passed_tests + 1
    println()

    total_tests = total_tests + 1
    var result_minus int = minus()
    print("minus() (aliased from subtract) = ")
    println(result_minus)
    assert(result_minus == 35, "minus() should return 35")
    println("  ✓ minus() == 35")
    passed_tests = passed_tests + 1
    println()

    // Test 3: Python-style from...import
    println("─────────────────────────────────────────────────")
    println("[Test 3] Python-style: from \"...\" import a as x")
    println("─────────────────────────────────────────────────")
    total_tests = total_tests + 1
    var result_times int = times()
    print("times() (aliased from multiply) = ")
    println(result_times)
    assert(result_times == 42, "times() should return 42")
    println("  ✓ times() == 42")
    passed_tests = passed_tests + 1
    println()

    // Test 4: Mixed usage of regular and aliased imports
    println("─────────────────────────────────────────────────")
    println("[Test 4] Mixed Regular and Aliased Imports")
    println("─────────────────────────────────────────────────")
    total_tests = total_tests + 1
    var sum int = add() + plus()
    print("add() + plus() = ")
    println(sum)
    assert(sum == 60, "sum should be 60 (30 + 30)")
    println("  ✓ Both regular and aliased imports work together")
    passed_tests = passed_tests + 1
    println()

    // Test 5: Private function encapsulation
    println("─────────────────────────────────────────────────")
    println("[Test 5] Private Function Encapsulation")
    println("─────────────────────────────────────────────────")
    total_tests = total_tests + 1
    var result5 int = calculate_area()
    print("calculate_area() = ")
    println(result5)
    println("  (internally calls private _get_width()=5 and _get_height()=8)")
    assert(result5 == 40, "calculate_area() should return 40 (5*8)")
    println("  ✓ calculate_area() == 40")
    passed_tests = passed_tests + 1
    println()

    total_tests = total_tests + 1
    var result6 int = get_pi_times_100()
    print("get_pi_times_100() = ")
    println(result6)
    println("  (internally calls private _pi_constant())")
    assert(result6 == 314, "get_pi_times_100() should return 314")
    println("  ✓ get_pi_times_100() == 314")
    passed_tests = passed_tests + 1
    println()

    // Test 6: Multiple imports from same module (deduplication)
    println("─────────────────────────────────────────────────")
    println("[Test 6] Multiple Imports from Same Module")
    println("─────────────────────────────────────────────────")
    total_tests = total_tests + 1
    println("  Testing that multiple import statements from")
    println("  the same module don't cause duplicate symbols...")
    var combo int = multiply() + divide()
    print("multiply() + divide() = ")
    println(combo)
    assert(combo == 52, "combo should be 52 (42 + 10)")
    println("  ✓ Module deduplication works correctly")
    passed_tests = passed_tests + 1
    println()

    // Summary
    println("╔════════════════════════════════════════════════╗")
    println("║              Test Summary                      ║")
    println("╚════════════════════════════════════════════════╝")
    print("Total tests: ")
    println(total_tests)
    print("Passed: ")
    println(passed_tests)
    print("Failed: ")
    println(total_tests - passed_tests)
    println()

    assert(passed_tests == total_tests, "All tests should pass")

    println("╔════════════════════════════════════════════════╗")
    println("║   ✅ All module import tests passed!          ║")
    println("╚════════════════════════════════════════════════╝")
    println()
    println("Tested features:")
    println("  ✓ Traditional: import { a, b } from \"...\"")
    println("  ✓ Simplified: import a as x from \"...\"")
    println("  ✓ Python-style: from \"...\" import a as x")
    println("  ✓ Import aliases (as keyword)")
    println("  ✓ Multiple imports from same module")
    println("  ✓ Module deduplication")
    println("  ✓ Private function encapsulation")
}
